package model;

import java.io.Serializable;
import javax.persistence.*;

import dao.HotelDao;


/**
 * The persistent class for the horder database table.
 * 
 */
@Entity
@NamedQuery(name="Horder.findAll", query="SELECT h FROM Horder h")
public class Horder implements Serializable {
	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private HorderPK id;

	private int money;
	private int status;
	
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	//bi-directional many-to-one association to Hotel
	@ManyToOne
	@JoinColumn(name="h_email",insertable=false, updatable=false )
	private Hotel hotel;

	//bi-directional many-to-one association to Tourist
	@ManyToOne
	@JoinColumn(name="t_email",insertable=false, updatable=false)
	private Tourist tourist;

	public Horder() {
	}

	public HorderPK getId() {
		return this.id;
	}

	public void setId(HorderPK id) {
		this.id = id;
	}

	public int getMoney() {
		return this.money;
	}

	public void setMoney(int money) {
		this.money = money;
	}

	public Hotel getHotel() throws Exception {
		Hotel hotel1 = HotelDao.getHotelNoCache(id.getHEmail());
		System.out.println("wshv"+hotel1.getEmail());
		return hotel1;
	}

	public void setHotel(Hotel hotel) {
		this.hotel = hotel;
	}

	public Tourist getTourist() {
		return this.tourist;
	}

	public void setTourist(Tourist tourist) {
		this.tourist = tourist;
	}

}